package com.anne.fish.model;

import static javax.persistence.GenerationType.IDENTITY;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
@Entity
@Table(name = "score", catalog = "fish")
@Searchable
@XmlRootElement
public class Score extends BaseObject implements Serializable {
	private Long id;
	private String project;
	private Long score;
	private Long createTime;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@SearchableId
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "project", nullable = false)
	@SearchableProperty
	public String getProject() {
		return this.project;
	}

	public void setProject(String project) {
		this.project = project;
	}

	@Column(name = "score", nullable = false)
	@SearchableProperty
	public Long getScore() {
		return this.score;
	}

	public void setScore(Long score) {
		this.score = score;
	}

	@Column(name = "create_time", nullable = false)
	@SearchableProperty
	public Long getCreateTime() {
		return this.createTime;
	}

	@Transient
	public String getCreateTimeStr() {
		return super.convert(getCreateTime());
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Score pojo = (Score) o;

		if (project != null ? !project.equals(pojo.project)
				: pojo.project != null)
			return false;
		if (score != null ? !score.equals(pojo.score) : pojo.score != null)
			return false;
		if (createTime != null ? !createTime.equals(pojo.createTime)
				: pojo.createTime != null)
			return false;

		return true;
	}

	public int hashCode() {
		int result = 0;
		result = (project != null ? project.hashCode() : 0);
		result = 31 * result + (score != null ? score.hashCode() : 0);
		result = 31 * result + (createTime != null ? createTime.hashCode() : 0);

		return result;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer(getClass().getSimpleName());

		sb.append(" [");
		sb.append("id").append("='").append(getId()).append("', ");
		sb.append("project").append("='").append(getProject()).append("', ");
		sb.append("score").append("='").append(getScore()).append("', ");
		sb.append("createTime").append("='").append(getCreateTime())
				.append("'");
		sb.append("]");

		return sb.toString();
	}

}
